package com.example.mo.allfind.ui.persional;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.mo.allfind.R;
import com.example.mo.allfind.ui.MainActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SettingActivity extends AppCompatActivity {
    @Bind(R.id.title_bar)
    RelativeLayout titleBar;
    @Bind(R.id.set_warn)
    LinearLayout setWarn;
    @Bind(R.id.set_safe)
    LinearLayout setSafe;
    @Bind(R.id.textView)
    TextView textView;
    @Bind(R.id.set_clear)
    LinearLayout setClear;
    @Bind(R.id.set_btn_quit)
    Button setBtnQuit;
    private TextView common_title_bar_left, tv_title;
    private SharedPreferences sp;
    private SharedPreferences.Editor editor;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        ButterKnife.bind(this);
        sp = getSharedPreferences("userInfo",MODE_PRIVATE);
        editor = sp.edit();
        common_title_bar_left = (TextView) findViewById(R.id.common_title_bar_left);
        tv_title = (TextView) findViewById(R.id.tv_title);
        common_title_bar_left.setVisibility(View.VISIBLE);
        common_title_bar_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        tv_title.setText("设置");
    }

    @OnClick({R.id.title_bar, R.id.set_warn, R.id.set_safe, R.id.set_clear, R.id.set_btn_quit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_bar:
                Toast.makeText(this,"title_bar",Toast.LENGTH_SHORT).show();
                break;
            case R.id.set_warn:
                Toast.makeText(this,"set_warn",Toast.LENGTH_SHORT).show();
                break;
            case R.id.set_safe:
                Toast.makeText(this,"set_safe",Toast.LENGTH_SHORT).show();
                break;
            case R.id.set_clear:
                Toast.makeText(this,"set_clear",Toast.LENGTH_SHORT).show();
                break;
            case R.id.set_btn_quit:
                startActivity(new Intent(SettingActivity.this, MainActivity.class));
                editor.putInt("state",0);
                editor.putInt("auto",0);
                editor.commit();
                finish();
                break;
        }
    }
}
